<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页案例</title>
    <link rel="shortcut icon" href="/images/index/logo.ico">
    <style>
        .refresh {
            display: inline-block;
            float: right;
        }
    </style>
</head>
<body>


<div class="refresh">
    <button class="btn btn-info search" title="刷新" data-url="/indexCase/admin/list"><span
            class="glyphicon glyphicon-refresh"></span></button>
</div>
<div class="">
    <ol class="breadcrumb">
        <li><a href="javascript:;">首页管理</a></li>
        <li class="active">首页案例更换</li>
    </ol>
</div>
<div class="banner_show">
    <table class="table table-bordered table-responsive">
        <tr>
            <th>id</th>
            <th>主题名称</th>
            <th>下载量</th>
            <th>图片</th>
            <th>操作</th>
        </tr>
        <c:forEach var="data" items="${dataMap}">
            <tr>
                <td class="id">${data.id}</td>
                <td><p>${data.title}</p></td>
                <td class="download"><p>${data.down}</p></td>
                <td class="pro_img"><img src="/indexCase/admin/image?image=${data.image}" alt="" width="180px"
                                         height="200px">
                    <input type="file" class="hidden" name="image" accept="image/png,image/gif,image/jpg"></td>
                <td class="operate ">
                    <button class=" btn btn-info banner_active start_stop" data-state="${data.state}"><c:if
                            test="${data.state}">禁用</c:if><c:if
                            test="${data.state==false}">启用</c:if></button>
                    <a href="/themeScreenshot/user/lists?tid=${data.tid}&bimage=${data.bimage}" target="_blank">
                        <button class=" btn btn-success">预览</button>
                    </a>
                    <button class=" btn btn-danger delete">删除</button>
                </td>
            </tr>
        </c:forEach>

    </table>
</div>
<button class="btn btn-info add" data-url="/indexCase/admin/addIndex">
    <span class="glyphicon glyphicon-plus"></span>添加
</button>

<script>

    $(document).ready(function () {
        operate_btn();
        $('.search').click(function () {
            var scope = $(this);
            $('.content_right').load(scope.attr('data-url'));
            toast_text('刷新成功', 600);
        });
        $('.add').click(function () {
            $('.content_right').load($(this).attr('data-url'));
        });
//删除操作
        $('.delete').click(function () {
            var scope = $(this);
            var id = $(this).parent().siblings('.id').text();
            custom_modal('你确定要删除么？');
            $('.modal_footer button').eq(0).unbind().click(function () {
                $.post("/indexCase/admin/delete", {id: id}, function (data) {
                    if (data.code == 200) {
                        scope.parents('tr').remove();
                    }
                    $('.modal_1').fadeOut();
                    toast_text(data.msg, 600);
                })
            });

        });


        $('.start_stop').unbind().click(function () {
            var scope = $(this);
            start_top('/indexCase/admin/changeState', $(this).parent().siblings('.id').text(), $(this).attr('data-state'), '/indexCase/admin/list');
        });
//    ---------------图片展示---------------
        img_click(3, 360, 400);

    });

</script>
</body>
</html>